<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>点击一下，添加一张图片</title>
		<script>
			function addImg(o){
				var im=document.createElement("img");
				im.setAttribute("src","../images/game01.jpg");
				im.setAttribute("width","300px");
				im.setAttribute("height","200px");
				
				//document.body.appendChild(im);
				//document.body.insertBefore(im,o);
				document.getElementById("d").appendChild(im);
			}
			function cloneDiv(){
				var d=document.getElementById("d");
				let d2=d.cloneNode(true);
				document.body.insertBefore(d2,document.body.firstElementChild);
			}
			function delImg()
			{
				var d=document.getElementById("d");
				d.removeChild(d.firstElementChild);//删除第一张照片
			}
		</script>
	</head>
	<body>
		<input type="button" value="添加图片" onclick="addImg(this)"/>
		<input type="button" value="克隆div" onclick="cloneDiv()"/>
		<input type="button" value="删除图片" onclick="delImg()"/>
		<div id="d" style="border:4px solid gold;border-radius: 30px;"></div>
	</body>
</html>
